#include <cmath>
#include <iostream>
using namespace std;

bool isBeauty(int a, int b, int m) {
  return abs(a - b) <= m;
}
int resolve(int nums[], int n, int m) {
  int count;
  if (n == 2) {
    isBeauty(nums[0], nums[1], m) ? count = 1 : count = 0;
  } else {
    count = 0;
    for (int i = 1; i < n; i++) {
      int temp = resolve(nums + i + 1, n - i - 1, m);
      // 包含 nums[i]
      if (isBeauty(nums[0], nums[i], m)) {
        count += pow(2, n - i - 1);
      } else {
        count += temp;
      }
      // 不包含 nums[i]
      count += temp;
    }
  }
  return count;
}

int main() {
  // 输入
  int m, n;
  cin >> n >> m;
  int nums[n];
  for (int i = 0; i < n; i++) {
    cin >> nums[i];
  }
  // 输出
  cout << resolve(nums, n, m) << endl;
  return 0;
}